#include <stdio.h>
#include <string.h>
void bytebit(unsigned char a)
{
    int i;
    for(i=0; i<8; i++) {
        printf("%d : %d\n", i, (a >> (8-1-i)) & 0x1);

    }
}


void intbit(int a)
{
    printf("%6d : ", a);
    int i;
    for(i=0; i<32; i++) {
        printf("%d", (a >> (32-1-i)) & 0x1);
        if(i+1 % 8 == 0) {
            printf(" ");
        }
    }
    printf("\n");
}


int main()
{
    char s[] = {0x00, 0xc8};
    int a = (s[0] << 8 ) | (s[1] & 0xff);
    printf("a=%d.\n", a);

    int b = s[1];
    int n = 0xff;
    printf("b=%d, b&0xff=%d, b&n=%d\n", b, b&0xff, b&n);

    
    unsigned char uch;
    memcpy(&uch, &b, 1);
    printf("uch = %d\n", uch);
    bytebit(uch);
    bytebit(0xff);
    bytebit(200);

    intbit(-56);
    intbit(200);
    intbit(0xff);

    printf("%s=%d", "-56&255", (int)((int)-56&(int)255));
    
    return 0;

}







